package com.dqhl.community.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;

import com.dqhl.community.R;

/**
 * Created by Administrator on 2016/9/5.
 * 评价成功的dialog
 */

public class EvaluateSuccessDialog extends Dialog implements View.OnClickListener{
    private Context context;

    private ImageViewClickListener imageViewClickListener;

    public void setButtonClickListener(ImageViewClickListener imageViewClickListener) {
        this.imageViewClickListener = imageViewClickListener;
    }

    public EvaluateSuccessDialog(Context context) {
        super(context, R.style.CustomDialog);
        this.context = context;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();
    }

    private void initView() {
        LayoutInflater inflater = LayoutInflater.from(context);
        View view = inflater.inflate(R.layout.dialog_evaluate_success, null);
        setContentView(view);

        ImageView ivCancel = (ImageView) view.findViewById(R.id.iv_cancel);

        ivCancel.setOnClickListener(this);

        Window window = getWindow();
        WindowManager.LayoutParams lp = window.getAttributes();
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        lp.width = (int) (dm.widthPixels * 0.8);
        window.setAttributes(lp);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.iv_cancel:
                imageViewClickListener.doCancel();
                break;
        }
    }

    public interface ImageViewClickListener {
        void doCancel();
    }
}